package com.sloth.bear.controller;

import com.sloth.bear.dto.vo.FileUploadVo;
import com.sloth.bear.service.FileService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 文件上传管理
 */
@Slf4j
@RestController
@RequestMapping("/file")
@RequiredArgsConstructor
public class FileController {

    private final FileService fileService;

    /**
     * 上传图片
     */
    @PostMapping("/upload/image")
    public FileUploadVo uploadImage(@RequestParam("file") MultipartFile file) {
        log.info("接收到图片上传请求，文件名: {}, 大小: {} bytes", 
                file.getOriginalFilename(), file.getSize());
        
        return fileService.uploadImage(file);
    }
}